#ifndef BOSS_Afterburner_Globals_Functions_TermionalIO_H
#define BOSS_Afterburner_Globals_Functions_TermionalIO_H

#include "TString.h"
#include <string>
#include <unordered_map>

#define PRINT_DEBUG() BOSS_Afterburner::TerminalIO::PrintDebug(__FILE__, __LINE__, __func__)

namespace BOSS_Afterburner
{
  /// @addtogroup Afterburner_functions
  /// @{
  /// Namespace containing functions related to debugging and making macro's handle errors.
  /// @author  Remco de Boer 雷穆克 (r.e.deboer@students.uu.nl or remco.de.boer@ihep.ac.cn)
  /// @date    November 20th, 2018
  namespace TerminalIO
  {
    void PrintDebug(const char* file, int line, const char* func = nullptr);
    void CheckMainArguments(int argc, char* argv[], int required = 1);
    void ColourPrint(const char code, const TString& message, const TString& quantifier = "");
    void PrintBold(const TString& message);
    void PrintHeader(const TString& message, char sign = '=');
    void PrintFatalError(const TString& message);
    void PrintError(const TString& message);
    void PrintSuccess(const TString& message);
    void PrintWarning(const TString& message);
    bool IsEmptyPtr(void* ptr);
    template <class TYPE>
    inline bool MapHasKey(std::unordered_map<std::string, TYPE>& map, const std::string& key);
  } // namespace TerminalIO
  /// @}
} // namespace BOSS_Afterburner

/// Returns `true` if `map` has a certain `key`, and returns `false` if not`.
/// This function makes use of `map::find`.
template <class TYPE>
inline bool BOSS_Afterburner::TerminalIO::MapHasKey(std::unordered_map<std::string, TYPE>& map,
                                                    const std::string&                     key)
{
  return map.find(key) != map.end();
}

#endif